﻿#include "stdafx.h"
#include "XLinkIntParser.h"

#include "XBSTR.h"
#include "XString.h"
#include "Util.h"
#include "IXLink.h"

#include "ParseHelper.h"


CXLinkIntParser::CXLinkIntParser() : CXIntParserBase(&TIntCreateControl<IXLink>)
{
    ;
}

CXLinkIntParser::~CXLinkIntParser()
{
    ;
}

// 填充属性
BOOL CXLinkIntParser::FillAttr(IN IXConfigNode* pNode, IN IXControl* pControl)
{
    BOOL bResult = m_ParentParser.FillAttr(pNode, pControl);
    if(!bResult)
        return bResult;

    XBSTR bstrTemp;
    BOOL bTemp;
    COLORREF clrTemp;

    IXLink* pLink = Util::QueryIntf<IXLink>(pControl);
    if(pLink == NULL)
        return FALSE;

    // Link
    if(SUCCEEDED(pNode->GetValue(_T("link"), &bstrTemp)))
    {
        pLink->put_Link(bstrTemp);
    }

    // NormalColor
    if(SUCCEEDED(pNode->GetValue(_T("clrNormal"), &clrTemp)))
    {
        pLink->put_NormalColor(clrTemp);
    }

    // AllColor
    if(SUCCEEDED(pNode->GetValue(_T("clrAll"), &clrTemp)))
    {
        pLink->put_AllColor(clrTemp);
    }

    // HoverColor
    if(SUCCEEDED(pNode->GetValue(_T("clrHover"), &clrTemp)))
    {
        pLink->put_HoverColor(clrTemp);
    }

    // LinkMode
    if(SUCCEEDED(pNode->GetValue(_T("mode"), &bTemp)))
    {
        pLink->put_LinkMode(bTemp);
    }

    return bResult;
}
